<template>
  <el-header>
    <div>
      <img src="../../../assets/images/logo.png" width="40" alt="" />
      <h2>商城后台管理系统</h2>
    </div>
    <el-button type="danger" @click="logout">退出</el-button>
  </el-header>
</template>

<script>
import { checkLogout } from "../../../api/adminApi";
export default {
  methods: {
    async logout() {
      let res = await checkLogout();
      if (res.status == 1) {
        this.$message.success(res.msg);
        window.sessionStorage.removeItem("token");
        this.$router.replace("/denglu");
      } else {
        return this.$message.error(res.msg);
      }
    },
  },
};
</script>

<style lang="less" scoped>
.el-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #909399;
  div {
    display: flex;
    align-items: center;
    h2 {
      margin-left: 20px;
    }
  }
}
</style>